rest_{$this->post_type}_item_schema
Filter HookDescription
Filters the post's schema. The dynamic portion of the filter, `$this->post_type`, refers to the post type slug for the controller. Possible hook names include: - `rest_post_item_schema` - `rest_page_item_schema` - `rest_attachment_item_schema`Hook Information
File Location |
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
View on GitHub
|
Hook Type | Filter |
Line Number | 2748 |
Hook Parameters
Type | Name | Description |
---|---|---|
array
|
$schema
|
Item schema data. |
Usage Examples
Basic Usage
<?php
// Hook into rest_{$this->post_type}_item_schema
add_filter('rest_{$this->post_type}_item_schema', 'my_custom_filter', 10, 1);
function my_custom_filter($schema) {
// Your custom filtering logic here
return $schema;
}
Source Code Context
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php:2748
- How this hook is used in WordPress core
<?php
2743 *
2744 * @since 5.4.0
2745 *
2746 * @param array $schema Item schema data.
2747 */
2748 $schema = apply_filters( "rest_{$this->post_type}_item_schema", $schema );
2749
2750 // Emit a _doing_it_wrong warning if user tries to add new properties using this filter.
2751 $new_fields = array_diff( array_keys( $schema['properties'] ), $schema_fields );
2752 if ( count( $new_fields ) > 0 ) {
2753 _doing_it_wrong(
PHP Documentation
<?php
/**
* Filters the post's schema.
*
* The dynamic portion of the filter, `$this->post_type`, refers to the
* post type slug for the controller.
*
* Possible hook names include:
*
* - `rest_post_item_schema`
* - `rest_page_item_schema`
* - `rest_attachment_item_schema`
*
* @since 5.4.0
*
* @param array $schema Item schema data.
*/
Quick Info
- Hook Type: Filter
- Parameters: 1
- File: wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
Related Hooks
Related hooks will be displayed here in future updates.